<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>管理入口-用户信息列表</title>

<%@ include file="../common.jsp"%>
<script type="text/javascript" src="${path }/static/vender/jquery/jquery.pagination.js"></script>

<style type="text/css">
.main h4 {
	padding-top: 11px !important;
}
</style>
</head>

<body>
	<%@ include file="../header.jsp"%>

	<div class="container-fluid main" style="margin-left: 12%; margin-right: 12%; margin-top: 2%;">
		<h1 class="page-header">
			${user.userName } <span style="font-size: 15px;">(<c:if test="${user.role == 0}">普通用户</c:if><c:if test="${user.role == 1}">健步组长</c:if><c:if test="${user.role == 999}">超级管理员</c:if>)</span>
			<button id="modifyPassword" type="button" class="btn btn-primary pull-right">修改密码</button>
		</h1>
		<h4>
			上次登录时间：<span style="font-size: 15px;"><fmt:formatDate value="${user.lastLoginTime }" pattern="yyyy-MM-dd HH:mm:ss" /></span>
		</h4>
		<h4>
			上次登录IP：<span style="font-size: 15px;">${user.loginIp }</span>
		</h4>
		<h4>注册时间：<span style="font-size: 15px;"><fmt:formatDate value="${user.createTime }" pattern="yyyy-MM-dd HH:mm:ss" /></span></h4>
	</div>


	<div id="addPanel" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">修改密码</h4>
				</div>
				<div class="modal-body">
					<form id="addWalkerForm">
						<div class="form-group">
							<label for="recipient-name" class="control-label">旧密码:</label> <input type="text" class="form-control" check-type="required" id="oldPassword">
						</div>
						<div class="form-group">
							<label for="message-text" class="control-label">新密码:</label> <input type="text" class="form-control" check-type="required" id="newPassword">
						</div>
						<div class="form-group">
							<label for="message-text" class="control-label">重复密码:</label> <input type="text" class="form-control" check-type="required repeat" repeat-target="newPassword">
						</div>
						<div class="form-group">
							<div id="msgDiv" class="alert alert-success" style="display: none;" role="alert"></div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button id="modifyRectBtn" type="button" class="btn btn-primary">修改</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->

	<div id="setWalkerGroupPanel" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">指定用户拥有的健步组</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<c:forEach var="walkerGroup" items="${walkerGroups }">
							<label class="checkbox-inline"> <input type="checkbox" value="${walkerGroup.id }"> ${walkerGroup.groupName }
							</label>
						</c:forEach>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button id="saveWalkerGroupRectBtn" type="button" class="btn btn-primary">保存</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->

	<jsp:include page="${pagePath }/footer.jsp"></jsp:include>

	<script type="text/javascript">
		$("#addPanel").validation({
			reqmark : false,
			icon : false
		});

		$("#modifyPassword").click(function() {
			$("#addPanel").modal({
				backdrop : 'static',
				keyboard : false
			});
		});

		$("#modifyRectBtn").click(function() {
			if ($("#addPanel").valid() == false)
				return false;
			$.post("${path }/user/modifyPasswd", {
				oldPassword : $("#oldPassword").val(),
				newPassword : $("#newPassword").val() 
			}, function(data, status) {
				$("#msgDiv").show().html(data.msg);
				if (data && data.status == true) {
					$("#msgDiv").attr("class", "alert alert-success");
					$("#userName").val('');
					$("#password").val('');
				} else {
					$("#msgDiv").attr("class", "alert alert-warning");
				}
			});
		});
	</script>
</body>
</html>